package com.hwg;

import java.util.concurrent.ThreadPoolExecutor;

public class MultiThread {
    public static void main(String[] args) {
        System.out.println("Many threads running");
        ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 10, 2000, java.util.concurrent.TimeUnit.MILLISECONDS, new java.util.concurrent.ArrayBlockingQueue<Runnable>(5));
        executor.submit(() -> {
            Thread.currentThread().setName("我的名字是1号男嘉宾");
            while (true) {
                double res = Math.tan(1) + Math.tan(2) + Math.tan(3) + Math.tan(4) + Math.tan(5) + Math.tan(6) + Math.tan(7) + Math.tan(8) + Math.tan(9) + Math.tan(10);
            }

        });
        executor.submit(() -> {
            Thread.currentThread().setName("我的名字是2号男嘉宾");
            while (true) {
                double res = Math.tan(1) + Math.tan(2) + Math.tan(3) + Math.tan(4) + Math.tan(5) + Math.tan(6) + Math.tan(7) + Math.tan(8) + Math.tan(9) + Math.tan(10);
            }
        });
        executor.submit(() -> {
            Thread.currentThread().setName("我的名字是3号男嘉宾");
            while (true) {
                double res = Math.tan(1) + Math.tan(2) + Math.tan(3) + Math.tan(4) + Math.tan(5) + Math.tan(6) + Math.tan(7) + Math.tan(8) + Math.tan(9) + Math.tan(10);
            }
        });



    }
}